﻿using System;

namespace b2
{
    class Program
    {
        //求最大值的方法
        static int maxNum(int[] nums)
        {
            int max = -99999;
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] > max)
                {
                    max = nums[i];
                }
            }
            return max;
            /*另一个不靠谱的思路（会改变原数组
             Array.Sort(nums);
            Array.Reverse(nums);
            return nums[0];
            */
        }
        //求最小值的方法
        static int minNum(int[] nums)
        {
            int min = 99999;
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] < min)
                {
                    min = nums[i];
                }
            }
            return min;
        }
        //求和的方法
        static int getSum(int[] nums)
        {
            int sum = 0;

            for (int i = 0; i < nums.Length; i++)
            {
                sum += nums[i];
            }
            return sum;
        }
        //求平均值的方法
        static double getAve(int []nums)
        {
            int sum = getSum(nums);
            
            
            return sum / nums.Length;
        }
            static void Main(string[] args)
        {
            int []arrayNum = new int[13] { 89, 2, 45, 5, 3, 2, 4, 5, 34, 5, 78, 0, 20 };
            Console.WriteLine("最大值：" + maxNum(arrayNum));
            Console.WriteLine("最小值：" + minNum(arrayNum));
            Console.WriteLine("和：" + getSum(arrayNum));
            Console.WriteLine("平均数：" + getAve(arrayNum));

        }
    }
}
